package fschmidt.tools.web;

import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import luan.LuanState;
import luan.modules.web.HttpLuan;
import luan.LuanException;


public final class LuanRun extends HttpServlet {
	protected static LuanState luan = LuanState.newStandard();
	static {
		luan.eval("_G.String = require 'String'");
		luan.eval("_G.Table = require 'Table'");
		luan.eval("_G.Io = require 'Io'");
		luan.eval("_G.Math = require 'Math'");
		luan.eval("_G.Java = require 'Java'");
		luan.eval("_G.Html = require 'Html'");
	}

	protected void service(HttpServletRequest request,HttpServletResponse response)
		throws IOException
	{
		try {
			HttpLuan.service(luan,request,response,"web/web_run");
		} catch(LuanException e) {
			throw new RuntimeException(e);
		}
	}
}
